package org.istt.model;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.istt.web.WebConstants;


public class FileView implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private String approver;
	
	private Long approverId;
	
	private String approvedDate;

	private String categoryName;

	private String id;

	private String inprogress;

	private String receivedDate;

	private String submitter;
	
	private String regulationTime;
	
	private float remainingTime;
	
	private boolean isOverTime = false;

	private boolean isNew = false;
	
	DateFormat dateFormat = new SimpleDateFormat(WebConstants.DATE_TIME_FORMAT);
	public FileView() {
	}

	public String getApprovedDate() {
		return approvedDate;
	}

	public String getCategoryName() {
		return categoryName;
	}

	public String getId() {
		return id;
	}

	public String getInprogress() {
		return inprogress;
	}

	public String getReceivedDate() {
		return receivedDate;
	}

	public String getRegulationTime() {
		return regulationTime;
	}

	public void setApprovedDate(Date approvedDate) {
		if(approvedDate!=null)
			this.approvedDate = dateFormat.format(approvedDate);;
	}
	
	public void setCategoryName(String categoryName) {
		this.categoryName = categoryName;
	}
	public void setId(String id) {
		this.id = id;
	}
	public void setInprogress(Date receivedDate, Date approvedDate, float processTime, float workingDay) {
		if(approvedDate!=null){
//			this.remainingTime = processTime-(float)((approvedDate.getTime() - receivedDate.getTime())/(1000 * 60 * 60 * 24) - workingDay);
			this.remainingTime = processTime-workingDay;
			if(this.remainingTime >= 0){
				this.inprogress = "\u0110\u00FAng h\u1EA1n";
			}else if(this.remainingTime < 0){
				this.inprogress = "Tr\u1EC5 h\u1EA1n ("+(float)Math.abs(this.remainingTime) + " ng\u00E0y)";
				this.isOverTime = true;
			}
		}else{
			Date today = new Date(); 
//			this.remainingTime = processTime-(float)((today.getTime() - receivedDate.getTime())/(1000 * 60 * 60 * 24) - workingDay);
			this.remainingTime = processTime - workingDay;
			if(this.remainingTime >= 0){
				this.inprogress = "C\u00F2n "+this.remainingTime+" ng\u00E0y";
			}else if(this.remainingTime < 0){
				this.inprogress = "Tr\u1EC5 h\u1EA1n ("+(float)Math.abs(this.remainingTime) + " ng\u00E0y)";
				this.isOverTime = true;
			}
		}
	}
	
	public void setReceivedDate(Date receivedDate) {
		if(receivedDate!=null)
			this.receivedDate = dateFormat.format(receivedDate);
	}

	public void setRegulationTime(float regulationTime) {
		this.regulationTime = regulationTime + " ng\u00E0y";
	}

	public void setOverTime(boolean isOverTime) {
		this.isOverTime = isOverTime;
	}

	public boolean isOverTime() {
		return isOverTime;
	}

	public void setRemainingTime(float remainingTime) {
		this.remainingTime = remainingTime;
	}

	public float getRemainingTime() {
		return remainingTime;
	}

	public void setApprover(String approver) {
		this.approver = approver;
	}

	public String getApprover() {
		return approver;
	}

	public void setNew(boolean isNew) {
		this.isNew = isNew;
	}

	public boolean isNew() {
		return isNew;
	}

	public void setApproverId(Long approverId) {
		this.approverId = approverId;
	}

	public Long getApproverId() {
		return approverId;
	}

	public void setSubmitter(String submitter) {
		this.submitter = submitter;
	}
	/**
	 * Nguoi dung ten ho so
	 * @return
	 */
	public String getSubmitter() {
		return submitter;
	}

}
